Function Reference

_TS_TaskRegister

Register or update a Task.

#Include <TaskScheduler.au3>
_TS_TaskRegister($oService, $sFolder, $sName, $oTaskDefinition, $sUserId = "", $sPassword = "", $iLogonType = Default, $iCreateFlag = $TASK_CREATE)

 

Parameters

$oService Task Scheduler Service object as returned by _TS_Open
$sFolder Folder where the Task should be created
$sName Name of the Task
$oTaskDefinition Task Definition object as created by _TS_TaskCreate and filled by _TS_TaskPropertiesSet
$sUserId [optional] The user credentials that are used to register the Task. If present, these credentials
$sPassword [optional] The password for the UserId that is used to register the Task. When the TASK_LOGON_SERVICE_ACCOUNT logon type
$iLogonType [optional] Can be any of the TASK_LOGON_TYPE constants enumeration. For the default please check Remarks
$iCreateFlag [optional] Defines if to create or update the task. Can be any of the TASK_CREATE constants enumeration. Default is $TASK_CREATE

 

Return Value

Success: Task object
Failure: Returns 0 and sets @error:
    2101 - Parameter $oService is not an object or not an ITaskService object
    2102 - $sFolder does not exist or an error occurred in _TS_FolderExists. @extended is set to the COM error (if any)
    2103 - Task exists which is incompatible with flags $TASK_CREATE, $TASK_DISABLE and $TASK_CREATE or
    Task does not exist which is incompatible with flags $TASK_UPDATE And $TASK_DONT_ADD_PRINCIPAL_ACE
    2104 - Parameter $oTaskDefinition is not an object or not an ITaskDefinition object
    2105 - Error accessing $sFolder using _TS_FolderGet. @extended is set to the COM error
    2106 - Error creating the Task. @extended is set to the COM error

 

Remarks

If the logon type has been set in the Principal sub-object then $TASK_LOGON_NONE is the default to not overwrite the existing setting.
Else $TASK_LOGON_INTERACTIVE_TOKEN will be used as default.

 

Related

 

Example


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <MsgBoxConstants.au3>

MsgBox($MB_ICONINFORMATION, "Task Scheduler UDF", "Please check example script _TS_TaskCreate.au3 for how to use _TS_TaskRegister!")